Skip to content

fix(pm-aggregator): escape unknown /item subjects against reflected XSS - #4419

Merged
dezren39 merged 3 commits into
mainfrom
queue/3422-2267-aggregator-item-escape
Nov 3, 2026
Merged

dezren39 merged 3 commits into
mainfrom
queue/3422-2267-aggregator-item-escape

Conversation

@dezren39

@dezren39 dezren39 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Fixes #2267.

Reflected XSS: for an unknown /item/<subject> URL, the decoded subject was interpolated unescaped into the HTML not-found response, so a crafted link (e.g. /item/%3Cimg%20src%3Dx%20onerror%3D...%3E) returned an executable element in the aggregator origin.

Changes (scope: pm-stack/aggregator/src/server.ts + aggregator tests only)

  • server.ts: escape the decoded missing-item subject with the renderer's existing esc helper before including it in the 404 HTML.
  • server.ts: escape the two sibling raw-interpolation 404s in the same file (quota-service id, program project id). Both are regex-constrained to [\w-] today, so they cannot break out of <code> — escaped anyway so the class is closed, not just the one line.
  • test/error-boundary-1211.test.ts: new HTTP regression — an unknown /item/ subject containing <img src=x onerror="...">& returns 404 with the subject as inert escaped text and no executable <img> element.

Out of scope / not touched: error-boundary.ts notFoundResponse interpolates the raw page path into its HTML 404 (<code>${path}</code>) — same reflection class, reachable for unknown page routes. Left alone per this task's server.ts-only scope; happy to file a follow-up if wanted.

Verification (local laptop, fixtures source)

  • bun test test/error-boundary-1211.test.ts test/path-segment.test.ts test/boot.test.ts: 40 pass, 0 fail
  • Full bun test in pm-stack/aggregator (after bun install for declared deps): 1101 pass, 0 fail
  • Live fixture-server probe: /item/%3Cimg...%3E and /item/%3Cscript%3E... both return 404 with &lt;img...&gt; / &lt;script&gt; inert text; known /item/<id> still 200
  • bunx tsc --noEmit: fails on pre-existing unrelated errors (projects.ts, push.ts web-push typings, several test fixtures); none in the changed files
  • git diff --check: clean

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-03T11:54:05.170865Z
We couldn’t complete this review. Comment @codex review to try again.
bd026c7 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Resolve server.ts conflict: keep main's multi-line 404 render and the
escaped subject (esc(id)) from the reflected-XSS fix.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant